/**
 * @移位函数
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	() 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>

unsigned int shift(unsigned int value, int n);

int main(void) {
	unsigned int w1 = 0177777u, w2 = 0444u;

	printf("%o %o\n", shift(w1, 5), w1 << 5);
	printf("%o %o\n", shift(w1, -6), w1 >> 6);
	printf("%o %o\n", shift(w2, 0), w2 >> 0);
	printf("%o\n", shift(shift(w1, -3), 3));
	return 0;
}

unsigned int shift(unsigned int value, int n) {
	if (n > 0) {
		value <<= n;
	} else {
		value >>= -n;
	}

	return value;
}
